<?php
/**
 * Created by PhpStorm.
 * User: liu85
 * Date: 2017/12/28
 * Time: 23:23
 */

namespace app\common\model;


use think\Model;

class Base extends Model
{
    const DEFAULT_PAGE = 1;
    const DEFAULT_PAGESIZE = 20;

    const DEFAULT_SORT = 'sort DESC,id DESC';
    const CREATED_SORT = 'created DESC';

    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        $className = get_class($this);
        $className::beforeInsert(function (){
            $this->updated = time();
            $this->created = time();
            $this->is_deleted = 0;
        });

        $className::beforeUpdate(function (){
            $this->updated = time();
        });
    }



}